//
// Created by 王书哲 on 25-3-15.
//
#include <stdio.h>
#include <string.h>

char * s_gets(char *, int);
int main(void)
{
    char nums[30];
    printf("Please input a number:");
    char *res = s_gets(nums, 30);
    printf("result: %s \n", res);
    return 0;
}
char * s_gets(char * st, int n)
{
    char * ret_val;
    ret_val = fgets(st, n, stdin);
    if (ret_val)
    {
        while (*st != '\n' && *st != '\0')
            st++;
        if (*st == '\n')
            *st = '\0';
        else
            while (getchar() != '\n')
                continue;
    }
    return ret_val;
}